/**
 * @Author：ming
 * @Date：2023/10/29 12:50 PM
 * @Filename：Hot438
 */

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author ming
 */
public class Hot438 {
    public List<Integer> findAnagrams(String s, String p) {
        int len = p.length();
        char[] c = p.toCharArray();
        Arrays.sort(c);
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i <= s.length()-len; i++) {
           String sub = s.substring(i,i+len);
            char[] cc = sub.toCharArray();
            Arrays.sort(cc);
            if(Arrays.equals(c,cc)){
                list.add(i);
            }

        }

        return list;
    }
}
